﻿using System;
using System.Threading.Tasks;
using winS.winML;

namespace winS.Unity.Serialization
{
    public class Deserializer
    {
        private readonly WinMLDeserializer winMLDeserializer = new WinMLDeserializer();

        public Deserializer()
        {
            WinMLForUnity.AddToDeserializer(winMLDeserializer);
        }

        public T Deserialize<T>(string text)
        {
            return winMLDeserializer.Deserialize<T>(text);
        }
        public T DeserializeFromFile<T>(string filePath)
        {
            return winMLDeserializer.DeserializeFromFile<T>(filePath);
        }

        public async Task<T> DeserializeAsync<T>(string text)
        {
            return await winMLDeserializer.DeserializeAsync<T>(text);
        }
        public async Task<T> DeserializeFromFileAsync<T>(string filePath)
        {
            return await winMLDeserializer.DeserializeFromFileAsync<T>(filePath);
        }

        public void AddCustomDeserializationFunction<T>(Func<string, T> deserializationFunction)
        {
            winMLDeserializer.AddDeserializationFunction(deserializationFunction);
        }
    }
}